Removing Paradox master password
You can use below procedure to remove a Paradox table master password:
procedure RemoveMasterPassword(Table: TTable);
const
RESTRUCTURE_FALSE = WordBool(0);
var
TblDesc: CRTblDesc;
hDb: hDBIDb;
begin
{ Make sure that the table is opened and is exclusive }
if (Table.Active = False) or (Table.Exclusive = False) then
raise EDatabaseError.Create('Table must be opened in exclusive mode to add passwords');
{ Initialize the table descriptor }
FillChar(TblDesc, SizeOf(CRTblDesc), 0);
with TblDesc do
begin
{ Place the table name in descriptor }
StrPCopy(szTblName, Table.TableName);
{ Place the table type in descriptor }
StrCopy(szTblType, szPARADOX);
{ Set bProtected to False }
bProtected := RESTRUCTURE_FALSE;
end;
{ Get the database handle from the cursor handle }
Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
{ Close the table }
Table.Close;
{ Add the master password to the Paradox table }
Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, FALSE));
{ Re-Open the table }
Table.Open;
end;
Example of calling procedure
- Drop a Table.
- Set table's DatabaseName to any Alias and TableName to any Paradox table.
- Add bde to Unit1 uses section and make sure that DBTables and Db also added to
uses section.
- Copy and paste above procedure in Unit1.
- Drop a button.
- At button's OnClick event write:
Table1.Close;
Table1.Exclusive:= True;
Table1.Open;
RemoveMasterPassword(Table1);
Notes:
- Befor removing password you have to make sure that the table is opened in exclusive
mode.
- You can not remove any Paradox table until you open it first, opening a table
which have a password cann't be opened until it's password was entered.
See also
Setting Paradox master password